﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace TileEngine.tiles
{
    class DefaultWall:Iwall
    {
        public int x;
        public int y;
        #region dynamic methods
        virtual public bool isObstacle(){
            return true;
        }
        virtual public bool isStep()
        {
            return true;
        }

        virtual public Type getItemType()
        {
            return null;
        }
        virtual public Texture2D getTexture()
        {
            return Textures.empty;
        }


        virtual public bool breakTile()
        {
            return false;
        }
        virtual public void rightClick()
        {
        }
        virtual public void leftClick()
        {
        }

        virtual public int getWidht()
        {
            return Global.tileSize.X;
        }
        virtual public int getHeight()
        {
            return Global.tileSize.Y;
        }
        virtual public int getHardness()
        {
            return 0;
        }
        virtual public double getLightAbsorption()
        {
            return 0.5;
        }
        virtual public Color getLight()
        {
            return Color.Black;
        }
        virtual public void draw(SpriteBatch spriteBatch, Point destinationPoint, Color tint)
        {
            int frame = 0;
            if (Global.currentWorld.tiles[x, y - 1].wall != null)
                frame += 8;
            if (Global.currentWorld.tiles[x + 1, y].wall != null)
                frame += 4;
            if (Global.currentWorld.tiles[x, y + 1].wall != null)
                frame += 2;
            if (Global.currentWorld.tiles[x - 1, y].wall != null)
                frame += 1;
            spriteBatch.Draw(getTexture(), new Rectangle(destinationPoint.X, destinationPoint.Y, 20, 20),
                new Rectangle((frame % 4) * 20, ((int)(frame / 4)) * 20, 20, 20), tint);
        }
        #endregion

        #region static methods
        public object Clone()
        {
            return base.MemberwiseClone();
        }  
        virtual public void setCoord(int x, int y)
        {
            this.x = x;
            this.y = y;
        }

        #endregion
    }
}
